<template>
  <el-dialog
    :visible.sync="visible"
    custom-class="operate-dialog"
    title=""
    :show="show"
    width="350px"
    top="40vh"
    :show-close="true"
    :close-on-press-escape="false"
    :close-on-click-modal="false"
    @close="OnClose">
    <div class="content">
      <div class="content-text">{{text}}</div>
      <div class="btn" @click="go">{{btnText}}</div>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    name: 'operateDialog',
    props: {
      show: { type: Boolean, default: false }
    },
    data() {
      return {
        visible: this.show,
        text: '充值vip会员后才能获取发票，快去充值吧！',
        btnText: '去充值',
        status: '',
        type: '', //1 首页获取发票 2发票列表页获取
      }
    },
    watch: {
      show: {
        handler(show) {
          this.visible = this.show
        }
      }
    },
    methods: {
      OnClose() {
        this.$emit('update:show', false)
      },
      go(){ //跳转
        this.visible = false
        this.OnClose
        if (this.status === 557 || this.status === 558 || this.status === 559){
          switch (this.type) {
            case 1:
              this.$parent.goVip()
              break
            case 2:
              this.$router.push({name:'mine', params:{activeName: 'second'}})
              break
          }
        } else if(this.status === 555 || this.status === 556) {
          switch (this.type) {
            case 1:
              this.$parent.goMailBox()
              break
            case 2:
              this.$router.push({name:'mine', params:{activeName: 'four'}})
              break
          }

        }
      },
      /**
       * 展示dialog
       * @param tx 内容
       * @param b 按钮内容
       * @param s 状态值
       * @param t 类型值
       */
      showO(tx, b, s, t){
        this.text = tx
        this.btnText = b
        this.status = s
        this.type = t
        this.visible = true
      }
    }
  }
</script>

<style lang="scss" scoped>


  /deep/ .el-dialog{
    box-shadow: 0px 6px 11px 1px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
  }
  .operate-dialog{
    box-shadow:0px 6px 11px 1px rgba(0, 0, 0, 0.1);
    border-radius:10px;
    .content{
      width: 100%;
      text-align: center;
      .content-text{
        padding: 0 5px 30px 5px;
        color: #333333;
        font-size:20px;
        font-weight: 500;
      }
      .btn{
        width: 150px;
        margin: 0 auto;
        line-height: 40px;
        border-radius:10px;
        cursor: pointer;
        background-color: #3B83FC;
        color: #FFFFFF;
        font-size: 18px;
        font-weight: 500;
      }
    }
  }

</style>
